package com.zhengtoudai.ui.presenter;

import android.content.Context;

import com.zhengtoudai.base.LowBasePresenter;
import com.zhengtoudai.ui.bean.MyFragmentModel;
import com.zhengtoudai.ui.view.MyFragmentView;
import com.zhengtoudai.http.HttpApi;
import com.zhengtoudai.http.callback.ApiCallback;
import com.zhengtoudai.http.callback.SubscriberCallBack;

/**
 * 作者：黑哥 on 2016/8/25 11:37
 */
public class MyFragmentPresenter extends LowBasePresenter<MyFragmentView>{

    public MyFragmentPresenter(MyFragmentView view) {
        attachView(view);
    }

    public void loadData(Context context) {
        mvpView.showLoading();
        addSubscription(HttpApi.getInstance().getAccount(),new SubscriberCallBack<>(context,new ApiCallback<MyFragmentModel>() {
            @Override
            public void onSuccess(MyFragmentModel model) {
                mvpView.getDataSuccess(model);
            }

            @Override
            public void onFailure(int code, String msg) {
                mvpView.getDataFail(msg);
            }

            @Override
            public void onCompleted() {
                mvpView.hideLoading();
            }

            @Override
            public void onError(Throwable e) {

            }
        }));

    }




}
